function w = getWindow(wind,N,D)
% getWindow(wind,N,D)
% 	Parameters:
% 		wind:	Name of window to be sampled and returned
% 		N:	kernel size
% 		D:	Displacement parameter required of lagrange window
% 
% 	Outputs:
% 		w	sequence representing the sampling of the window function.
% 
% 	Purpose of this code:  This is a code that will return a sequence that represents a sample of
% 	the given window function of a particular size.
% 
% if nargin < 3, D = 0; end

% compute window
k = (-(N-1)/2):1:((N-1)/2); % kernel index 
switch lower(wind)
    case {'rectangular','boxcar','none'}
        w = ones(1,N);
    case 'blackman'
        s = (2*pi*k)/(N-1);
        w = 0.42+0.5*cos(s)+0.08*cos(2*s);
    case 'dblackman'
        s = (2*pi*k)/(N-1);
        w = -0.5*sin(s)-0.16*sin(2*s);
    case 'blackman3'
        s = (2*pi*k)/(N-1);
        w = (0.42+0.5*cos(s)+0.08*cos(2*s)).^3;
    case 'dblackman3'
        s = (2*pi*k)/(N-1);
        w = 3*((0.42+0.5*cos(s)+0.08*cos(2*s)).^2).*(-0.5*sin(s)-0.32*cos(s).*sin(s));
    case 'lagrange'
        td = (N-1)/2+D;
        b1 = gamma(td+1)/(gamma(N+1)*gamma(td-N+1));
        b2 = gamma(N)./(gamma(k+(N-1)/2+1).*gamma(N-k-(N-1)/2));
        w = ((pi*N)/(sin(pi*td)))*b1*b2;
    case 'flattop'
        w = flattopwin(N)';
    otherwise
        error('Error: unknown window');
end